package 剑指offer;

import leetcode.day_2020_12_14_12_21.TreeNode;

public class Offer54_JZ62 {
    int res = 0, k;
    public int kthLargest(TreeNode root, int k) {
        this.k = k;
        track(root);
        return res;
    }

    public void track(TreeNode root) {
        if (root != null) {
            track(root.right);
            k-=1;
            if (k == 0) {
                res = root.val;
                return;
            }
            track(root.left);
        }
    }
}
